package com.free.normal;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

/**
 * <p>
 * Title: Eclipse Plugin Development
 * </p>
 * <p>
 * Description: Free download
 * </p>
 * <p>
 * mail: ganshm@gmail.com
 * </p>
 */

public class HelloWorldText
{
    
    public static void main(String[] args)
    {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new GridLayout(1, false));
        // 添加单行文本框
        new Text(shell, SWT.BORDER);
        // 添加右对齐单行文本框
        new Text(shell, SWT.RIGHT | SWT.BORDER);
        // 添加以密码形式显示的文本框
        new Text(shell, SWT.PASSWORD | SWT.BORDER);
        // 添加只读文本框
        new Text(shell, SWT.READ_ONLY | SWT.BORDER).setText("Read Only");
        // 添加多行显示文本框
        Text t = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
        // 给文本属性赋值
        t.setText("very long sting test!very long sting test!very long sting test!very long sting test!");
        
        t.setLayoutData(new GridData(GridData.FILL_BOTH));
        shell.setSize(200, 200);
        shell.open();
        while (!shell.isDisposed())
        {
            if (!display.readAndDispatch())
            {
                display.sleep();
            }
        }
        display.dispose();
    }
}
